package cn.usian.controller;

import cn.usian.pojo.User;
import cn.usian.service.UserService;
import com.google.j2objc.annotations.ReflectionSupport;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
@RefreshScope
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("findById")
    public User findById(Integer id){
        System.out.println("1111111");
        return userService.findByUserId(id);
    }


    @GetMapping("/findId/{id}")
    public User findId(@PathVariable Integer id){
        return userService.findByUserId(id);
    }

    @PostMapping("save")
    public boolean save(@RequestBody User user){
        int sout=userService.save(user);
        if (sout>0){
            return true;
        }else
            return false;
    }

    @GetMapping("/findByNameId/{id}/{username}")
    public User findByNameId(@PathVariable Integer id,@PathVariable String username){
        System.out.println("=============="+id+"========"+username);
        return userService.findByUserId(id);
    }
}
